package org.example;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JDBCDemo {
        static String url = "jdbc:mysql://localhost:3306/pet_store?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
        static String user = "root";        //
        static String password = "123456";  //

    public static Connection getConnection() throws SQLException {
        return DriverManager.getConnection(url, user, password);
    }
        public static void main(String[] args){
            try {
                Connection conn = DriverManager.getConnection(url, user, password);
                System.out.println("连接成功！");
                conn.close();
            } catch (SQLException e) {
                System.out.println("连接失败" + e.getMessage());
                e.printStackTrace();
            }

        }
    }

